<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    protected $fillable = [
        'name', 'sort', 'movies_count', 'is_show'
    ];

    public function scopeSortOrder($query)
    {
        // 按照排序值排序
        return $query->orderBy('sort');
    }

    public function movies()
    {
        return $this->belongsToMany(Movie::class);
    }
}
